package com.example.stgv;

import java.util.ArrayList;

import android.app.Activity;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;

public class ListClass extends Activity {
	DBHelper db;
	LopHocsData lop = new LopHocsData();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_class);
		ArrayList<LopHocsData> arrLop = new ArrayList<LopHocsData>();
		db = new DBHelper(this);
		try {
			Cursor cur1 = db.getAllData(lop.getDATABASE_TABLE_LOP(),
					lop.getKEY_MALOP());
			if (cur1.moveToFirst()) {
				do {
					LopHocsData lop1 = new LopHocsData();
					lop1.setKEY_MALOP(cur1.getString(0));
					lop1.setKEY_MALOP(cur1.getString(1));
					lop1.setKEY_MALOP(cur1.getString(2));
					lop1.setKEY_MALOP(cur1.getString(3));
					arrLop.add(lop1);
				} while (cur1.moveToNext());
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		db.close();
	}
	
	/*private void fillData() {
	    String[] menuCols = new String[] { "Mã Lớp", "Năm học", "Tên Lớp", "Sỉ số" };
	    int[] to = new int[] { R.id.list_malop, R.id.list_namhoc, R.id.list_tenlop,R.id.list_siso };

	    MatrixCursor menuCursor = new MatrixCursor(menuCols);
	    extracted(menuCursor);
	    db = new DBHelper(this);
		try {
			Cursor cur1 = db.getAllData(lop.getDATABASE_TABLE_LOP(),
					lop.getKEY_MALOP());
			if (cur1.moveToFirst()) {
				do {
					LopHocsData lop1 = new LopHocsData();
					lop1.setKEY_MALOP(cur1.getString(0));
					lop1.setKEY_MALOP(cur1.getString(1));
					lop1.setKEY_MALOP(cur1.getString(2));
					lop1.setKEY_MALOP(cur1.getString(3));
					menuCursor.addRow(lop1);
				} while (cur1.moveToNext());
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		db.close();
	    
	    
	    menuCursor.addRow(new Object[] { R.drawable.chicken_sandwich, "Chicken Sandwich", "$3.99" });

	    SimpleCursorAdapter menuItems = new SimpleCursorAdapter(
	            this, R.layout.menu_row, menuCursor, menuCols, to);

	    setListAdapter(menuItems);
	}

	private void extracted(MatrixCursor menuCursor) {
		startManagingCursor(menuCursor);
	}*/
}
